<?php
/**
 * Created by PhpStorm.
 * UserModel: Administrator
 * Date: 2019/3/01/0001
 * Time: 10:02
 */
namespace app\caidongweb\controller;
use think\Controller;
use think\Db;
use think\Session;

/**
 * Class BaseController
 * 公共类
 * @package app\caidongweb\controller
 */
class BaseController extends Controller
{

    public function _empty(){
        $this->redirect("Error/index");
    }

    public function __construct()
    {
        parent::__construct();
        $this->checkLogin();
    }
    //检测登录状态
    public function checkLogin()
    {
        $session_uid = Session::get('usid');
        if(!$session_uid){
            return $this->redirect('Login/login');
        }else{
            return $this->fetch('index/index');
        }
    }

    /**
     * 删除表的指定数据
     * @param $table 表名
     * @param $where 主要条件
     * @return int
     */
    public function del($table,$where)
    {
        if(empty($where)){
            return false;
        }
        $res = Db::name($table)->where($where)->delete();
        return $res;
    }
}